package com.timber.util;


import java.awt.Color;
import java.sql.*;
import java.awt.Font;
import java.util.Vector;



/**
 *
 *	base class extended by objects displayed in tables
 *
 *	properties are used by DefaultSLObjectRenderer
 */
public class SLDataObjectRowAdaptor extends SLDataObjectAdaptor
{
    /**	row background	*/
  protected Color  bground = null;
  protected Vector bgColors = new Vector();

    /**	row foreground	*/
  protected Color  fground = null;
  protected Vector fgColors = new Vector();

    /**	row background when sorted */
    protected Color sortBGround = null;

    /**      row font	*/
  protected Font   font = null;

  //	table row, set when table model is created, used for updating cells
  protected Vector rowV;

  public Color getForeground( Object o, int c ) {
         Color aC = null;
         if (c < fgColors.size() && c > -1)
           aC = (Color) fgColors.get(c);
         return (aC == null) ? fground : aC;
  }
  public Color getBackground( Object o, int c ) {
         Color aC = null;
         if (c < bgColors.size() && c > -1)
           aC = (Color) bgColors.get(c);
         return (aC == null) ? getBackground() : aC;
  }

    /**
     *	return row background
     *	first look at row background, then sort background
     */
  public Color getBackground()
    {
	return (bground != null ? bground : sortBGround);
    }

  public Color getForeground() { return fground; }

  public Font  getFont() { return font;}

  public void setBackground( Color c ) { bground = c; }
  public void setForeground( Color c ) { fground = c; }

  public void setSortBackground( Color c )
  {
      sortBGround = c;
  }

    /**	set column background	*/
  public void setBackground( Color c, int col ) {
    if (c == null) return;
    bgColors.ensureCapacity(col);
    bgColors.insertElementAt(c, col);
  }

    /**	set column foreground	*/
  public void setForeground( Color c, int col ) {
    if (c == null) return;
    fgColors.ensureCapacity(col);
    fgColors.insertElementAt(c, col);
  }

  public boolean bgEquals(SLDataObjectRowAdaptor o) {
    return equals(o);
  }

  public void setFont( Font f ) { font = f; }

  public Vector getRowVector() { return rowV; }
  public void setRowVector( Vector v ) { rowV = v; }

}
